import { Team } from "./team";
export class Group{
    private id:number;
    private teams:Array<Team>;

    constructor(id:number){
        this.id = id;
        this.teams = new Array<Team>();
    }
    public add(team:Team){
        this.teams.push(team);
    }
    public isEmpty():boolean{
        return this.teams.length == 0;
    }
    public hasMember(id:number):boolean{
        for(let i=0;i<this.teams.length;++i){
            if(this.teams[i].getMember(id)){
                return true;
            }
        }
        return false;
    }
    public removeTeam(index:number):Team{
        return this.teams.splice(index,1)[0];
    }
    public clearTeam(index:number):void{
        return this.teams[index].clear();
    }
    public removeMember(id:number):boolean{
        for(let i=0;i<this.teams.length;++i){
            if(this.teams[i].removeById(id)){
                return true;
            }
        }
        return false;
    }
    public clear(){
        this.teams.length=0;
    }
    public getId():number{
        return this.id;
    }
    public getTeam(index:number){
        return this.teams[index];
    }
    public getTeams(){
        return this.teams;
    }
}